﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.startup {
    import flash.events.*;
    import flash.geom.*;
    import net.wooga.pets.events.*;
    import mx.utils.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class GameViewModel extends Actor {

        private var _gameViewScale:Number = 2
        private var _gameViewPosition:Point;
        private var _scaleFactors:Array;
        private var _mouseWheel:Boolean;
        private var _zoomingEnabled:Boolean;

        public static const MAX_SCALE:Number = 4;
        public static const MIN_SCALE:Number = 0.5;
        public static const ID:String = "GAME_VIEW";
        public static const SCALE_MIN:int = 0;
        public static const SCALE_4X4:int = 1;
        public static const SCALE_3X3:int = 2;
        public static const SCALE_2X2:int = 3;
        public static const SCALE_MAX:int = 4;
        public static const START_SCALE:Number = 2;
        public static const START_X_OFFSET:Number = 105;
        public static const START_Y_OFFSET:Number = -120;

        public function GameViewModel(){
            this._scaleFactors = [MIN_SCALE, 1, 1.5, 2, MAX_SCALE];
            super();
            this._gameViewPosition = new Point();
            this._zoomingEnabled = true;
        }
        public function get gameViewScale():Number{
            return (this._gameViewScale);
        }
        private function setGameViewScale(_arg1:Number):void{
            if (this._zoomingEnabled){
                this._gameViewScale = _arg1;
                dispatch(new Event(EventConstants.BEFORE_SCALE_CHANGED));
                dispatch(new Event(EventConstants.SCALE_CHANGED));
            };
        }
        public function get hospitalViewScale():Number{
            return ((GameConstants.HOSPITAL_SCALE * this._gameViewScale));
        }
        public function increaseScaleFactor(_arg1:Boolean):void{
            this._mouseWheel = _arg1;
            var _local2:int = ArrayUtil.getItemIndex(this._gameViewScale, this._scaleFactors);
            var _local3:int = (_local2 + 1);
            this.checkIndex(_local3);
        }
        public function decreaseScaleFactor(_arg1:Boolean):void{
            this._mouseWheel = _arg1;
            var _local2:int = ArrayUtil.getItemIndex(this._gameViewScale, this._scaleFactors);
            var _local3:int = (_local2 - 1);
            this.checkIndex(_local3);
        }
        public function getLeftNumberOfStepsToMax():int{
            var _local1:int = ArrayUtil.getItemIndex(this._gameViewScale, this._scaleFactors);
            return (((this._scaleFactors.length - _local1) + 1));
        }
        private function checkIndex(_arg1:int):void{
            if (this.isIndexValid(_arg1)){
                this.setGameViewScale(this._scaleFactors[_arg1]);
                this.checkIfMaxOrMinIndexIsReached(_arg1);
            };
        }
        private function checkIfMaxOrMinIndexIsReached(_arg1:int):void{
            if (_arg1 == 0){
                dispatch(new Event(EventConstants.MIN_SCALE_REACHED));
            } else {
                if (_arg1 == (this._scaleFactors.length - 1)){
                    dispatch(new Event(EventConstants.MAX_SCALE_REACHED));
                };
            };
        }
        private function isIndexValid(_arg1:int):Boolean{
            return ((((_arg1 >= 0)) && ((_arg1 < this._scaleFactors.length))));
        }
        public function get gameViewPosition():Point{
            return (this._gameViewPosition);
        }
        public function set gameViewPosition(_arg1:Point):void{
            this._gameViewPosition = _arg1;
            dispatch(new InfoEvent(EventConstants.SET_TO_POSITION, ID, {position:this._gameViewPosition}));
        }
        public function setGameScaleByIndex(_arg1:int):void{
            this.setGameViewScale(this._scaleFactors[_arg1]);
        }
        public function get mouseWheel():Boolean{
            return (this._mouseWheel);
        }
        public function setZoomingEnabled(_arg1:Boolean):void{
            this._zoomingEnabled = _arg1;
        }

    }
}//package net.wooga.pets.controllers.startup 
